/**
 * Created by IntelliJ IDEA.
 * User: mstine
 * Date: Mar 20, 2008
 * Time: 3:18:28 PM
 * To change this template use File | Settings | File Templates.
 */

class SmartPerson {
     String name
     Map relationships = [:]
     
     Object invokeMethod(String what, Object who) {
         if (relationships.containsKey(what)) {
             who.each{thisPerson ->
                relationships.get(what).add(thisPerson)
             }
         } else {
             relationships.put(what, who as List)
         }
     }
}

//Let's call methods that don't exist!

def matt = new SmartPerson(name:"Matt")

matt.married "Wendy"
matt.knows "Michael"
matt.worksWith "Mo"
matt.knows "Joel"
matt.worksWith "Sundeep"
matt.knows "Ken", "Robby", "Jerry"

println matt.relationships

//GOTO: expando.groovy